<template>
  <el-dialog v-model="dialogVisible" width="600px" append-to-body>
    <Title title="毕设简介" />
    <div class="dialog-container">
      <el-descriptions :column="1" border>
        <el-descriptions-item label="毕设名称">
          {{ teamInfo.teamName || '-' }}
        </el-descriptions-item>
        <el-descriptions-item label="队长">
          {{ leaderName }}
        </el-descriptions-item>
        <el-descriptions-item label="毕设简介" label-align="top">
          <div class="summary-text">
            {{ teamInfo.summary || '暂无简介' }}
          </div>
        </el-descriptions-item>
      </el-descriptions>
    </div>
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="close" class="defauleButton">关闭</el-button>
      </div>
    </template>
  </el-dialog>
</template>

<script setup>
import { ref, computed } from 'vue'
import Title from '@/components/Title/index.vue'

const dialogVisible = ref(false)
const teamInfo = ref({})

const leaderName = computed(() => {
  const leader = teamInfo.value.studentTeams?.find((st) => st.isLeader === '1')
  return leader?.student?.user?.nickName || '未知'
})

const openDialog = (team) => {
  teamInfo.value = team || {}
  dialogVisible.value = true
}

const close = () => {
  dialogVisible.value = false
}

defineExpose({ openDialog })
</script>

<style scoped lang="scss">
.dialog-container {
  padding: 10px 0;
}

.summary-text {
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 60px;
  color: #606266;
}
</style>
